//
//  Network.h
//  StandardizedProduct
//
//  Created by 宁宁 on 16/7/5.
//  Copyright © 2016年 ym. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AFHTTPSessionManager.h>

@class Network;
@protocol NetworkDelegate <NSObject>

- (void)Network:(Network *)request finished:(id )response;
- (void)Network:(Network *)request Error:(NSString *)error;

@end

@interface Network : NSObject

@property (assign) id <NetworkDelegate> delegate;

/**
 *[AFNetWorking]的operationManager对象
 */
@property (nonatomic, strong) AFHTTPSessionManager *operationManager;

/**
 *当前的请求operation队列
 */
@property (nonatomic, strong) NSOperationQueue *operationQueue;


/**
 *功能: 创建CMRequest的对象方法
 */
+ (instancetype)request;

/**
 *功能：GET请求
 *参数：(1)请求的MenthodName: MenthodNameString
 *     (2)请求成功调用的Block: success
 *     (3)请求失败调用的Block: failure
 */
- (void)GETMenthodName:(NSString *)MenthodNameString
            parameters:(NSDictionary*)parameters
               success:(void (^)(id object))success
               failure:(void (^)(NSError *error))failure;

/**
 *功能：POST请求
 *参数：(1)请求的MenthodName: MenthodNameString
 *     (2)POST请求体参数:parameters
 *     (3)请求成功调用的Block: success
 *     (4)请求失败调用的Block: failure
 */
- (void)POSTMenthodName:(NSString *)MenthodNameString
             parameters:(NSDictionary*)parameters
                success:(void (^)(id object))success
                failure:(void (^)(NSError *error))failure;

/**
 *功能：Login请求
 *参数：(1)请求的MenthodName: MenthodNameString
 *     (2)Login请求体参数:parameters
 *     (3)请求成功调用的Block: success
 *     (4)请求失败调用的Block: failure
 */
- (void)loginWithparameters:(NSDictionary*)parameters
                     success:(void (^)(id object))success
                     failure:(void (^)(NSError *error))failure;

/**
 *  post请求
 *
 *  @param URLString  请求网址
 *  @param parameters 请求参数
 */
- (void)postWithURL:(NSString *)URLString parameters:(NSDictionary *)parameters;

/**
 *  get 请求
 *
 *  @param URLString 请求网址
 */
- (void)getWithURL:(NSString *)URLString;

/**
 *取消当前请求队列的所有请求
 */
- (void)cancelAllOperations;


@end
